﻿using System;
using System.Runtime.Serialization;
using LiSA_Server.Base.NHibernate.Models;
using NHibernate;
using NHibernate.Mapping.ByCode.Conformist;

namespace LiSA_Service.Users.Models
{
    [DataContract]
    public class Person : Entity
    {

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public virtual string FirstName { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public virtual string MiddleName { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public virtual string LastName { get; set; }

        /// <summary>
        /// Gets or sets the phone number.
        /// </summary>
        [DataMember]
        public virtual string PhoneNumber { get; set; }

        /// <summary>
        /// Gets or sets the job-title.
        /// </summary>
        [DataMember]
        public virtual string Title { get; set; }

        /// <summary>
        /// Gets or sets the university of the person.
        /// </summary>
        [DataMember]
        public virtual Guid Organization { get; set; }

        /// <summary>
        /// Gets or sets the university of the person.
        /// </summary>
        [DataMember]
        public virtual DateTime Birthday { get; set; }
    }

    /// <summary>
    /// The person mapping.
    /// </summary>
    public class PersonMapping : ClassMapping<Person>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonMapping"/> class.
        /// </summary>
        public PersonMapping()
        {
            this.Property(x => x.FirstName);
            this.Property(x => x.MiddleName);
            this.Property(x => x.LastName);
            this.Property(x => x.PhoneNumber);
            this.Property(x => x.Title, x => x.Type(NHibernateUtil.StringClob));
            this.Property(x => x.Organization);
            this.Property(x => x.Birthday);
        }
    }
}